package vue;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import controleur.ControleBtnC0;


import modele.CKModel;

public class PanelC0 extends JPanel {
	
	CKModel<String, String> _modele;
	VueEditeurCK _vue;

	static final long serialVersionUID = 12345;
	private JLabel lblC0;
	private JTextField txtC0;
	private JLabel lblErrorC0;

	private JButton btnValiderC0;
	
	public PanelC0(CKModel<String, String> modele, VueEditeurCK vue){
		
		this._modele = modele;
		this._vue = vue;
		
		this.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();		
		
		lblC0 = new JLabel("Entrez un C0");
		lblC0.setPreferredSize(new Dimension(200,30));
		gbc.fill = GridBagConstraints.BOTH;
		gbc.anchor = GridBagConstraints.LINE_START;
		gbc.gridx = 0;
		gbc.gridy = 0;
		Insets i = new Insets(5, 5, 5, 5);
		gbc.insets = i;
		this.add(lblC0, gbc);
		
		txtC0 = new JTextField();
		txtC0.setPreferredSize(new Dimension(200,30));
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.gridx = 1;
		gbc.gridy = 0;
		this.add(txtC0, gbc);
		
		lblErrorC0 = new JLabel("");
		lblErrorC0.setPreferredSize(new Dimension(200,30));
		lblErrorC0.setForeground(Color.RED);
		gbc.anchor = GridBagConstraints.LINE_END;
		gbc.gridx = 2;
		gbc.gridy = 0;
		this.add(lblErrorC0, gbc);
		
		btnValiderC0 = new JButton("Valider");
		btnValiderC0.setPreferredSize(new Dimension(200,30));
		btnValiderC0.addActionListener(new ControleBtnC0(_modele, _vue));
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.gridx = 1;
		gbc.gridy = 2;
		this.add(btnValiderC0, gbc);
		

		
	}
	
	
	public String getTextC0(){
		return this.txtC0.getText();
	}
	


	/**
	 * @param lblErrorC0 the lblErrorC0 to set
	 */
	public void setLblErrorC0(String erreur) {
		this.lblErrorC0.setText(erreur);
	}


	/**
	 * @return the lblErrorC0
	 */
	public JLabel getLblErrorC0() {
		return lblErrorC0;
	}

	
}
